import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  UploadedFile,
  UseInterceptors,
} from '@nestjs/common';
import { IconListService } from './icon-list.service';
import { CreateIconListDto } from './dto/create-icon-list.dto';
import { UpdateIconListDto } from './dto/update-icon-list.dto';
import { Public } from 'src/common/decorators/public.decorator';
import { FileInterceptor } from '@nestjs/platform-express';

@Controller('icon-list')
export class IconListController {
  constructor(private readonly iconListService: IconListService) {}

  @Post('/upload')
  @Public()
  @UseInterceptors(FileInterceptor('file'))
  upload(@UploadedFile() file: any) {
    return this.iconListService.upload(file);
  }

  @Post('/creatIcon')
  create(@Body() createIconListDto: CreateIconListDto) {
    return this.iconListService.create(createIconListDto);
  }

  @Get('/groupList')
  getGroupList() {
    return this.iconListService.getGroupList();
  }

  @Get('/iconList/:id')
  findOne(@Param('id') id: number) {
    console.log(id);

    return this.iconListService.getIconList(id);
  }

  @Patch(':id')
  update(
    @Param('id') id: string,
    @Body() updateIconListDto: UpdateIconListDto,
  ) {
    return this.iconListService.update(+id, updateIconListDto);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.iconListService.remove(+id);
  }
}
